package com.applet.mallappletbackstage.service.impl;

import com.applet.mallappletbackstage.entity.Message;
import com.applet.mallappletbackstage.mapper.MessageMapper;
import com.applet.mallappletbackstage.service.MessageService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MessageServiceImpl extends ServiceImpl<MessageMapper, Message> implements MessageService {

    @Autowired
    MessageMapper messageMapper;

    @Override
    public int getCount(String id) {
        QueryWrapper<Message> messageQueryWrapper = new QueryWrapper<>();
        messageQueryWrapper.eq("user", id);
        messageQueryWrapper.eq("watched", 0);
        return messageMapper.selectCount(messageQueryWrapper);
    }
}
